
function PS_SPGridView_FilterCallbackHandler(result, context)
{
	var values=context.split(';');
	if (values.length !=4) { alert("ERROR: SPGridView_FilterCallbackHandler() - values.length !=4"); return; }
	var gridViewClientId=values[0];
	var templateClientId=values[1];
	var menuClientId=values[2];
	var dataFieldName=values[3];
	var gridView=document.getElementById(gridViewClientId);
	if (gridView==null) { alert("ERROR: SPGridView_FilterCallbackHandler() - gridView==null"); return; }
	var menuTemplate=document.getElementById(templateClientId);
	if (menuTemplate==null) { alert("ERROR: SPGridView_FilterCallbackHandler() - menuTemplate==null"); return; }
	var menu=document.getElementById(menuClientId);
	if (menu==null) { alert("ERROR: SPGridView_FilterCallbackHandler() - menu==null"); return; }
	var postbackEventReference=gridView.getAttribute("postbackEventReference");
	if ((postbackEventReference==null) || (postbackEventReference.length <=0)) { alert("ERROR: SPGridView_FilterCallbackHandler() - postbackEventReference is null or empty"); return; }
	var filterFieldName=gridView.getAttribute("filterFieldName");
	var filterFieldValue=gridView.getAttribute("filterFieldValue");
	var filterCurrentlyOn=false;
	if ((filterFieldName !=null) && (filterFieldName.length > 0) && (filterFieldName==dataFieldName))
	{
		filterCurrentlyOn=true;
	}
	SPGridView_FixupFilterValuesFromMenuTemplate(menuTemplate, filterCurrentlyOn);
	values=result.split(';');
	for (var valueIndex=0; valueIndex < values.length; valueIndex++)
	{
	    var rawValue=unescape(values[valueIndex]);
		var subValues=rawValue.split("##");
		var dispValue;
		var dataValue=subValues[0];
		if (1<subValues.length)
		{
		    dispValue=subValues[1];
	    }
		else 
		{
		    dispValue=dataValue;    
		}
		
		var script=postbackEventReference.replace(/__POSTBACKARGUMENT__/g, dataFieldName+";"+dataValue.replace(/\\/g, "\\\\").replace(/\'/g, "\\'").replace(/%/g, "%25").replace(/;/g, "%3b"));
		var newMenuItem=CAMOpt(menuTemplate, dispValue, script);
		newMenuItem.setAttribute("isFilterItem", "true");
		if (dataValue==filterFieldValue)
		{
			newMenuItem.setAttribute("checked", "true");
		}
	}
	HideMenu(menuTemplate);
	MMU_Open(menuTemplate, menu);
}

SPGridView_FilterCallbackHandler=PS_SPGridView_FilterCallbackHandler;